package com.zz.admin.internationalManagement.controller;

import com.zz.admin.internationalManagement.dto.I18nConfigDto;
import com.zz.admin.internationalManagement.service.I18nConfigService;
import java.util.List;
import java.util.Map;

import com.zz.common.base.dto.PageListResultDto;
import com.zz.common.base.dto.ResponseDTO;
import com.zz.common.base.dto.ResultDto;
import com.zz.common.constants.ApiConstants;

import io.swagger.annotations.Api;
import jakarta.annotation.Resource;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 国际化配置表 服务接口类
 * @author zhang.lei
 * @since 2025-07-13 14:12:57
 */
@Api(tags = "国际化配置表服务接口类")
@RestController
@RequestMapping("international-management/v1.0/i18n-config")
public class I18nConfigController {

    @Resource
    private I18nConfigService i18nConfigService;

    @RequestMapping(value = "/query-with-page", method = RequestMethod.POST)
    @ApiOperation(value = "国际化配置表-分页查询", notes = "传入分页信息")
    public PageListResultDto<I18nConfigDto> queryWithPage(@RequestBody I18nConfigDto i18nConfigDto) {
        PageListResultDto<I18nConfigDto> res;
        res = i18nConfigService.queryWithPage(i18nConfigDto, i18nConfigDto.getQueryParam());
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/query-with-no-page", method = RequestMethod.POST)
    @ApiOperation(value = "国际化配置表-不分页查询", notes = "传入查询条件信息")
    public ResponseDTO<List<I18nConfigDto>> queryWithNoPage(@RequestBody I18nConfigDto i18nConfigDto) {
        ResponseDTO<List<I18nConfigDto>> res = new ResponseDTO<>();
        res.setData(i18nConfigService.queryWithNoPage(i18nConfigDto));
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/query-by-locale/{locale}", method = RequestMethod.GET)
    @ApiOperation(value = "国际化配置表-查询ByLocale", notes = "传入locale")
    public ResponseDTO<Map<String, Map<String, Object>>> queryByLocale(@PathVariable("locale") String locale) {
        ResponseDTO<Map<String, Map<String, Object>>> res = new ResponseDTO<>();
        Map<String, Map<String, Object>> result = i18nConfigService.queryByLocale(locale);
        res.setData(result);
        return res;
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "国际化配置表-查询ById", notes = "传入id")
    public ResponseDTO<I18nConfigDto> queryById(@PathVariable("id") String id) {
        ResponseDTO<I18nConfigDto> res = new ResponseDTO<>();
        I18nConfigDto result = i18nConfigService.queryById(id);
        res.setData(result);
        return res;
    }

    @RequestMapping(value = "/query-by-ids", method = RequestMethod.POST)
    @ApiOperation(value = "国际化配置表-查询ByIds", notes = "传入ids")
    public ResponseDTO<List<I18nConfigDto>> queryByIds(@RequestBody List<String> ids) {
        ResponseDTO<List<I18nConfigDto>> res = new ResponseDTO<>();
        res.setData(i18nConfigService.queryByIds(ids));
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ApiOperation(value = "国际化配置表-创建", notes = "创建")
    public ResultDto save(@RequestBody I18nConfigDto i18nConfigDto) {
        ResultDto res = new ResultDto();
        i18nConfigService.save(i18nConfigDto);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/save-batch", method = RequestMethod.POST)
    @ApiOperation(value = "国际化配置表-创建", notes = "创建")
    public ResultDto saveBatch(@RequestBody List<I18nConfigDto> i18nConfigDtos) {
        ResultDto res = new ResultDto();
        i18nConfigService.saveBatch(i18nConfigDtos);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ApiOperation(value = "国际化配置表-修改", notes = "修改")
    public ResultDto modify(@RequestBody I18nConfigDto i18nConfigDto) {
        ResultDto res = new ResultDto();
        i18nConfigService.modify(i18nConfigDto);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/modify-batch", method = RequestMethod.POST)
    @ApiOperation(value = "国际化配置表-修改", notes = "修改")
    public ResultDto modifyBatch(@RequestBody List<I18nConfigDto> i18nConfigDtos) {
        ResultDto res = new ResultDto();
        i18nConfigService.modifyBatch(i18nConfigDtos);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "国际化配置表-删除ById", notes = "传入id")
    public ResultDto delete(@PathVariable("id")  String id) {
        ResultDto res = new ResultDto();
        i18nConfigService.delete(id);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

    @RequestMapping(value = "/delete-batch", method = RequestMethod.POST)
    @ApiOperation(value = "国际化配置表-批量删除", notes = "传入id")
    public ResultDto deleteBatch(@RequestBody List<String> ids) {
        ResultDto res = new ResultDto();
        i18nConfigService.deleteBatch(ids);
        res.setCode(ApiConstants.RESULT_SUCCESS);
        res.setMessage(ApiConstants.MESSAGE_SUCCESS);
        return res;
    }

}